﻿using NPOI.SS.Formula.Functions;

using PLCS.Application.Contracts.EquipmentApp.Dtos;
using PLCS.Application.Contracts.LogShowApp.Dtos;
using PLCS.Application.Contracts.TrayApp.Dtos;
using PLCS.Client.IService.LogManager;
using PLCS.Domain.Equipments;
using PLCS.Domain.Shared.Enums;
using PLCS.Domain.Stations;
using PLCS.Domain.Trays;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Volo.Abp.Application.Dtos;

namespace PLCS.Client.Service.LogManager
{
    public class OperationLogService : BaseService<OperationLogDto, OperationLogEditDto>, IOperationLogService
    {
        public async Task<PagedResultDto<OperationLogDto>> GetListBySearchAsync(int skipCount, int maxResultCount, string? startTime, string? endTime, string? view, string? operationType)
        {
            var route = $"operationLog/bySearch?SkipCount={skipCount}&MaxResultCount={maxResultCount}";
            if (!string.IsNullOrEmpty(startTime))
                route += $"&startTime={startTime}";
            if (!string.IsNullOrEmpty(endTime))
                route += $"&endTime={endTime}";
            if (!string.IsNullOrEmpty(view))
                route += $"&view={view}";
            if (!string.IsNullOrEmpty(operationType))
                route += $"&operationType={operationType}";

            RequestParam requestParam = new(method: Method.Get, route: route);
            var apiRes = await restClient.ExecuteAsync<PagedResultDto<OperationLogDto>>(requestParam);
            if (apiRes.Status)
                return apiRes.Data;
            else
                return new PagedResultDto<OperationLogDto>();
        }
    }
}